﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>驰骋工作流</title>
    <!-- 引用通用的js文件. -->
    <script language="JavaScript" src="/WF/Comm/JScript.js" type="text/javascript"></script>
    <script language="JavaScript" src="/WF/Comm/JS/Calendar/WdatePicker.js" defer="defer"type="text/javascript"></script>
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="../Img/ccbpm.ico" type="image/x-icon" />
    <script type="text/javascript" src="../Scripts/jquery-1.7.2.min.js"></script>
    <script language="JavaScript" src="../Comm/JScript.js"  type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/QueryString2016.js"></script>
     <!-- 导入配置文件. -->
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Comm/Gener.js"></script>

    <script type="text/javascript" language="javascript" >
        /*function Load() {

            var url = window.location.href;
            if (plant == "CCFlow") {
                url = url.replace('.htm', '.aspx');
                window.location.href = url;
                return;
            } else {
                url = url.replace('.htm', '.jsp');
                window.location.href = url;
                return;
            }
        }*/

        if (typeof FrmSubFlowSta == "undefined") {
            var FrmSubFlowSta = {}
            // 不可用
            FrmSubFlowSta.Disable = 0,
            // 可用
            FrmSubFlowSta.Enable = 1,
            // 只读
            FrmSubFlowSta.Readonly = 2

        }
        if (typeof SFShowCtrl == "undefined") {
            var SFShowCtrl = {}
            // 所有的子线程都可以看到
            SFShowCtrl.All = 0,
            // 仅仅查看我自己的
            SFShowCtrl.MySelf = 1

        }
        $(function () {

            //当IsShowTitle 不为0时，不显示标题
            if (GetQueryString("IsShowTitle") != undefined && GetQueryString("IsShowTitle") == 0) {
                $('#DelMsg table caption').hide();
            }

            //查询出来所有子流程的数据.
            var sf = new Entity("BP.WF.Template.FrmSubFlow", GetQueryString("FK_Node"));
            var node = new Entity("BP.WF.Node", GetQueryString("FK_Node"));
            if (sf.SFDefInfo.trim().Length == 0)
                return;

            var html = "";

            html += "<table width='100%'>";
            html += "<tr>";
            html += "<th class='TitleExt'>发起人</th>";
            html += "<th class='TitleExt'>标题</th>";
            html += "<th class='TitleExt'>停留节点</th>";
            html += "<th class='TitleExt'>状态</th>";
            html += "<th class='TitleExt'>处理人</th>";
            html += "<th class='TitleExt'>处理时间</th>";
            html += "<th class='TitleExt'>信息</th>";
            html += "</tr>";

            var emps = null;
            var strs = sf.SFDefInfo.split(',');
            var str;
            var tdHtml = "";
            var webUser = new WebUser();

            var workID = GetQueryString("WorkID");
            var flowNo = GetQueryString("FK_Flow");
            var nodeID = GetQueryString("FK_Node");


            //遍历子流程.
            for (var i = 0; i < strs.length; i++) {

                str = strs[i];
                if (str == null || str == "")
                    continue;
                if (str.length != 3)
                    continue;

                //输出标题.
                var fl = new Entity("BP.WF.Flow", str);

                if (sf.SFSta == FrmSubFlowSta.Enable && GetQueryString("DoType") != "View")
                    tdHtml = "<div style='float:left'><img src='../Img/Max.gif' />&nbsp;" + fl.Name + "</div> <div style='float:right'>[<a href=\"javascript:OpenIt('../MyFlow.htm?FK_Flow=" + fl.No + "&PWorkID=" + workID + "&PNodeID=" + nodeID + "&PFlowNo=" + flowNo + "&PFID=" + GetQueryString("FID") + "')\"  >" + sf.SFCaption + "</a>]</style>";

                if (sf.SFSta == FrmSubFlowSta.Readonly || GetQueryString("DoType") == "View")
                    tdHtml = "<div style='float:left'><img src='../Img/Max.gif' />&nbsp;" + fl.Name + "</div></style>";


                html += "<tr>";
                html += "<td class='TRSum' colspan=7 >" + tdHtml + "</td>";
                html += "</tr>";

                //该流程的子流程信息.
                var gwfs = new Entities("BP.WF.GenerWorkFlows");
                if (sf.SFShowCtrl == SFShowCtrl.All)
                    gwfs.Retrieve("PWorkID", GetQueryString("WorkID"), "FK_Flow", str); //流程.          
                else
                    gwfs.Retrieve("PWorkID", GetQueryString("WorkID"), "FK_Flow", str, "Starter", webUser.No); //流程.


                for (var j = 0; j < gwfs.length; j++) {

                    var item = gwfs[j];
                    if (item.WFState == 0)
                        continue;

                    html += "<tr>";
                    if (item.StarterName == null || item.StarterName == "")
                        html += "<td nowrap>&nbsp;</td>";
                    else
                        html += "<td nowrap>" + item.StarterName + "</td>";

                    if (item.TodoEmps.indexOf("" + webUser.No + "," + webUser.Name + ";") >= 0) {
                        html += "<td  style='word-break:break-all;' title='" + item.Title + "'>";
                        html += "<a href=\"javascript:OpenIt('../MyFlow.htm?WorkID=" + item.WorkID + "&FK_Flow=" + item.FK_Flow + "&IsCheckGuide=1&Frms=" + item.Paras_Frms + "&FK_Node=" + item.FK_Node + "&PNodeID=" + item.PNodeID + "&PWorkID=" + item.PWorkID + "')\" ><img src='../Img/Dot.png' width='9px' />&nbsp;" + item.Title + "</a></td>";
                    } else {
                        if (sf.SFOpenType == 0) {
                            html += "<td  style='word-break:break-all;' title='" + item.Title + "'>";
                            html += "<a href=\"javascript:OpenIt('../WFRpt.htm?WorkID=" + item.WorkID + "&FK_Flow=" + item.FK_Flow + "&PWorkID=" + item.PWorkID + "&PFlowNo=" + item.PFlowNo + "&PNodeID=" + item.PNodeID + "')\" ><img src='../Img/Dot.png' width='9px' />&nbsp;" + item.Title + "</a></td>";
                        } else {
                            html += "<td style='word-break:break-all;' title='" + item.Title + "'>";
                            html += "<a href=\"javascript:OpenIt('../WorkOpt/FoolFrmTrack.htm?WorkID=" + item.WorkID + "&FK_Flow=" + item.FK_Flow + "')\" ><img src='../Img/Dot.png' width='9px' />&nbsp;" + item.Title + "</a></td>";
                        }
                    }
                    //到达节点名称.
                    if (item.NodeName == null || item.NodeName == "")
                        html += "<td nowrap>&nbsp;</td>";
                    else
                        html += "<td nowrap>" + item.NodeName + "</td>";
                    //流程的状态 
                    if (item.WFStateText == null || item.WFStateText == "")
                        html += "<td nowrap>&nbsp;</td>";
                    else
                        html += "<td nowrap>" + item.WFStateText + "</td>";



                    //  var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
                    //   handler.AddPara("TodoEmps", item.TodoEmps);
                    //  emps = handler.DoMethodReturnString("DealUserInfoShowModel");

                    //到达人员.
                    html += "<td title='" + item.TodoEmps + "'>" + item.TodoEmps + "</td>";

                    //日期.
                    if (item.RDT == null || item.RDT == "")
                        html += "<td nowrap>&nbsp;</td>";
                    else
                        html += "<td nowrap>" + item.RDT + "</td>";

                    //流程备注.
                    if (item.FlowNote == null)
                        html += "<td title='" + item.FlowNote + "'></td>";
                    else
                        html += "<td title='" + item.FlowNote + "'>" + item.FlowNote + "</td>";


                    html += "</tr>";

                    //加载他下面的子流程.
                    //   html = InsertSubFlows(item.FK_Flow, item.FK_Node, item.WorkID, 1);
                }
            }


            html += "</table>";

            //   alert(html);

            $("#showMsg").html(html);
        })

        
       function InsertSubFlows(flowNo, fid, workid,layer,html){
            //该流程的子流程信息, 并按照流程排序.
            var gwfs = new Entities("BP.WF.GenerWorkFlows");
            gwfs.Retrieve("PWorkID", workid, "FK_Flow"); //流程.
            if (gwfs.Count == 0)
                return;

            var myFlowNo = "";
            var item=null;
            for (var i=0;i<gwfs.length;i++ )
            {
                item = gwfs[i];
                if (item.WFState == 0)
                    continue;

                if (myFlowNo.indexOf(item.FK_Flow)==-1)
                {
                    myFlowNo = myFlowNo + "," + item.FK_Flow;

                    //输出流程.
                    var fl = new Entity("BP.WF.Flow",item.FK_Flow);
                    var tdhtml = "<div style='float:left'>" + GenerSpace(layer * 2) + "<img src='../Img/Max.gif' />&nbsp;" + fl.Name + "</div>";
                    html+="<tr>";
                    html+="<td class='TRSum' colspan=6>"+tdhtml+"</td>";
                   html+="</tr>";
                }

                html+="<tr>";
                html+="<td style='word-break:break-all;' title='"+item.Title+"'> ";
                html+= GenerSpace(layer * 2) + "<a href=\"javascript:OpenIt('../WFRpt.htm?WorkID=" + item.WorkID + "&FK_Flow=" + item.FK_Flow + "')\" ><img src='../Img/Dot.png' width='9px' />&nbsp;" + item.Title + "</a></td>";
                
                //到达节点名称.
                if (item.NodeName == null || item.NodeName == "")
                    html += "<td nowrap>&nbsp;</td>";
                else
                    html += "<td nowrap>" + item.NodeName + "</td>";

                
                if (item.WFState ==3)
                    html += "<td nowrap>已完成</td>";
                else
                    html += "<td nowrap>未完成</td>";

                 //到达人员.
                htm +="<td title='" +item.TodoEmps + "'>"+item.TodoEmps+"</td>";

                //日期.
                if (item.RDT == null || item.RDT == "")
                    html += "<td nowrap>&nbsp;</td>";
                else
                    html += "<td nowrap>" + item.RDT + "</td>";

                //流程备注.
                htm += "<td title='" + item.FlowNote + "'>" + item.FlowNote + "</td>";
                    
                html += "</tr>";
                //加载他下面的子流程.
                InsertSubFlows(item.FK_Flow, item.FK_Node, item.WorkID, layer + 1,html);
            }
            return html;
        }

        function GenerSpace(spaceNum){
            if (spaceNum <= 0)
                return "";

            var strs = "";
            while (spaceNum != 0)
            {
                strs += "&nbsp;&nbsp;";
                spaceNum--;
            }
            return strs;
        }

        function RSize() {
            if (document.body.scrollWidth > (window.screen.availWidth - 100)) {
                window.dialogWidth = (window.screen.availWidth - 100).toString() + "px"
            } else {
                window.dialogWidth = (document.body.scrollWidth + 50).toString() + "px"
            }

            if (document.body.scrollHeight > (window.screen.availHeight - 70)) {
                window.dialogHeight = (window.screen.availHeight - 50).toString() + "px"
            } else {
                window.dialogHeight = (document.body.scrollHeight + 115).toString() + "px"
            }
            window.dialogLeft = ((window.screen.availWidth - document.body.clientWidth) / 2).toString() + "px"
            window.dialogTop = ((window.screen.availHeight - document.body.clientHeight) / 2).toString() + "px"
        }

        function NoSubmit(ev) {
            if (window.event.srcElement.tagName == "TEXTAREA")
                return true;

            if (ev.keyCode == 13) {
                window.event.keyCode = 9;
                ev.keyCode = 9;
                return true;
            }
            return true;
        }

        function OpenIt(url) {
            var newWindow = window.open(url, 'card', 'width=700,top=50,left=50,height=500,scrollbars=yes,resizable=yes,toolbar=false,location=false');
            newWindow.focus();
            return;
        }
    </script>
</head>
<body>

<form id="cc">

<center><div id="showMsg"> <img src='../Img/loading.gif' alt="" />正在加载，请稍后。。。 </div></center>
</form>

</body>
</html>
